package com.gdhengdian.collection._interface._impl;

import com.gdhengdian.collection._interface.Set;
import com.gdhengdian.tree_linkedList.BinarySearchTree;

/**
 * @author HD-0078 杨炜耀
 * @date 2021-4-7 15:27
 */
public class TreeSet<E extends Comparable<E>> implements Set<E> {

    private final BinarySearchTree<E> binarySearchTree;

    public TreeSet() {
        binarySearchTree = new BinarySearchTree<>();
    }

    @Override
    public void add(E e) {
        binarySearchTree.add(e);
    }

    @Override
    public void remove(E e) {
        binarySearchTree.remove(e);
    }

    @Override
    public boolean contains(E e) {
        return binarySearchTree.contains(e);
    }

    @Override
    public int size() {
        return binarySearchTree.size();
    }

    @Override
    public boolean isEmpty() {
        return binarySearchTree.isEmpty();
    }

    public void forEach() {
        binarySearchTree.preOrderNR();
    }
}
